package com.shujia.spark

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object Demo18Take {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setMaster("local")
      .setAppName("Demo14Agg")


    val sc = new SparkContext(conf)


    val studentsRDD: RDD[String] = sc.textFile("data/students.txt")

    /**
      * take： 取top,是一个action算子
      *
      */
    val top100: Array[String] = studentsRDD.take(1)
    top100.foreach(println)


    //获取第一条数据
    val first: String = studentsRDD.first()
    println(first)

  }

}
